package cn.com.gridinfo.sooc.core.expand.signin.activity;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.widget.ImageView;

import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;
import cn.com.gridinfo.sooc.R;
import cn.com.gridinfo.sooc.base.BaseSoocActivity;
import cn.com.gridinfo.sooc.core.expand.signin.fragment.HistorySignFragment;
import cn.com.gridinfo.sooc.core.expand.signin.fragment.TodaySignFragment;
import cn.com.gridinfo.sooc.utils.PagerAdapter;

/**
 * 签到界面
 *
 * @author yingchunli
 */
public class SigninActivity extends BaseSoocActivity {

    @InjectView(R.id.sliding_tabs_signin)
    TabLayout tabLayout;//标签栏
    @InjectView(R.id.viewpager_signin)
    ViewPager mViewPager;//ViewPager
    PagerAdapter adapter;//适配器
    String[] tabText  = {"今日签到", "历史签到"};// 选修卡文字

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.expand_signin);
        ButterKnife.inject(this);
        initView();//初始化界面数据
    }
    /**
     * 初始化界面数据
     */
    private void initView() {
        adapter = new PagerAdapter(getSupportFragmentManager());
        adapter.addFragment(TodaySignFragment.newInstance(""), tabText[0]);
        adapter.addFragment(HistorySignFragment.newInstance(""), tabText[1]);
        for (int i = 0; i < tabText.length; i++) {
            tabLayout.addTab(tabLayout.newTab().setText(tabText[i]));
        }
        mViewPager.setAdapter(adapter);
        tabLayout.setupWithViewPager(mViewPager);
    }

    @Override
    public String setupToolBarTitle() {
        return "签到";
    }

    @Override
    public boolean setupToolBarLeftButton(ImageView leftButton) {
        return true;
    }

    @Override
    public boolean setupToolBarRightButton(ImageView rightButton) {
        return false;
    }

    @OnClick(R.id.toolbar_leftbtn)
    void ontoolbarLeftClick() {
        finish();
    }
}
